﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Engine.Init {
    import flash.events.*;

    public class InitializationAction extends EventDispatcher {

        protected var _id:String;
        protected var _weight:int = 1;
        protected var _dependencies:Array;
        public var startTime:int;

        public function InitializationAction(_arg1:String):void{
            this._id = _arg1;
            this._dependencies = new Array();
        }
        public function addDependency(_arg1:String):void{
            if (this._dependencies.indexOf(_arg1) < 0){
                this._dependencies.push(_arg1);
            };
        }
        public function set weight(_arg1:int):void{
            if (this._weight == 1){
                this._weight = _arg1;
            } else {
                trace("re-bind weight");
            };
        }
        public function get weight():int{
            return (this._weight);
        }
        public function get progress():int{
            return ((this.hasCompleted()) ? this._weight : 0);
        }
        public function getDependencies():Array{
            return (this._dependencies);
        }
        public function getActionId():String{
            return (this._id);
        }
        public function isReady():Boolean{
            var _local1:Boolean;
            var _local2:int;
            while (_local2 < this._dependencies.length) {
                if (!InitializationManager.getInstance().hasActionCompleted(this._dependencies[_local2])){
                    _local1 = false;
                    break;
                };
                _local2++;
            };
            return (_local1);
        }
        public function hasCompleted():Boolean{
            return (InitializationManager.getInstance().hasActionCompleted(this._id));
        }
        public function execute():void{
            dispatchEvent(new Event(Event.COMPLETE));
        }

    }
}//package Engine.Init 
